#include "HighscoreText.h"
#include <iostream>


HighscoreText::HighscoreText(){}
HighscoreText::~HighscoreText(){}

void HighscoreText::initialize(sf::RenderWindow* window, int score, int yPos)
{
	m_renderWindow = window;
	scoreText = new sf::Text();
	scoreFont = new sf::Font();
	textColor = new sf::Color();
	textColor->r = 255;
	textColor->g = 198;
	textColor->b = 1;
	//textColor->a = 255;
	scoreFont->loadFromFile("Assets/Fonts/arial.ttf");
	scoreText->setFont(*scoreFont);
	scoreText->setCharacterSize(50);
	scoreText->setColor(*textColor);
	scoreText->setString(convertInt(score));
	scoreText->setPosition(sf::Vector2f(m_renderWindow->convertCoords(sf::Vector2i(1150, yPos))));
	
	
}

void HighscoreText::initialize(sf::RenderWindow* window, std::string name, int yPos)
{
	m_renderWindow = window;
	scoreText = new sf::Text();
	scoreFont = new sf::Font();
	textColor = new sf::Color();
	textColor->r = 255;
	textColor->g = 198;
	textColor->b = 1;

	scoreFont->loadFromFile("Assets/Fonts/arial.ttf");
	scoreText->setFont(*scoreFont);
	scoreText->setCharacterSize(50);
	scoreText->setColor(*textColor);

	scoreText->setString(name);
	scoreText->setPosition(sf::Vector2f(m_renderWindow->convertCoords(sf::Vector2i(715, yPos))));
}

void HighscoreText::update()
{
	m_renderWindow->draw(*scoreText);
}

std::string HighscoreText::convertInt(int number)
{
   std::stringstream ss;
   ss << number;
   return ss.str();
}

void HighscoreText::cleanup()
{
	delete scoreText;
	delete scoreFont;
	delete textColor;
}
